package br.ufpi.hu.prescricao.model;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
@Table(name = "laudo", schema = "public")
@SequenceGenerator(name="laudo_seq", sequenceName="public.laudo_seq", initialValue=1, allocationSize=1)
public abstract class Laudo implements BaseEntity {

	@Id
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="laudo_seq")
	private int id;

	@Column(nullable=false)
	private Date dataDeCriacao;

	@Column(nullable=false,name="id_paciente_aghu")
	private long idPacienteAghu;

	@ManyToOne(fetch = FetchType.EAGER, targetEntity = Usuario.class, optional = false)
	private Usuario usuarioDaSessao;
	
	@Column(nullable=false)
	private Date data;
	
	/**
	 * Descrição do laudo
	 * @return descrição
	 */
	public abstract String getTipo();
	
	/**
	 * Nome do arquivo PDF gerado
	 * @return nome
	 */
	public abstract String getNomeArquivo();

	public long getIdPacienteAghu() {
		return idPacienteAghu;
	}

	public void setIdPacienteAghu(long idPacienteAghu) {
		this.idPacienteAghu = idPacienteAghu;
	}

	public Date getDataDeCriacao() {
		return dataDeCriacao;
	}

	public void setDataDeCriacao(Date dataDeCriacao) {
		this.dataDeCriacao = dataDeCriacao;
	}

	public void cria() {
		this.dataDeCriacao = new Date();
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Usuario getUsuarioDaSessao() {
		return usuarioDaSessao;
	}
	
	public String getCriadoPor() {
		return "";
	}

	public void setUsuarioDaSessao(Usuario usuarioDaSessao) {
		this.usuarioDaSessao = usuarioDaSessao;
	}

	public String getNomeProfissionalSolicitante() {
		return "";
	}
	
	public String getCpf() {
		
		return "";
	}
	
	public String getCns() {
		
		return "";
	}
	
	public String getNumeroCnsSolicitante() {
		return "";
	}

	public Date getData() {
		return data;
	}
	
	public String getDataStr() {
		if (data!=null)
			return new SimpleDateFormat("dd/MM/yyyy").format(data);
		return "";
	}

	public void setData(Date data) {
		this.data = data;
	}
	
}
